package main

import (
	"flag"
	"fmt"
	"strconv"
	"strings"
)

type resource struct {
	url    string
	target string
	start  int
	end    int
}

func ruleResource() (res [] resource) {
	r1 := resource{
		url:    "http://localhost:8888",
		target: "",
		start:  0,
		end:    0,
	}

	r2 := resource{
		url:    "http://localhost:8888/list/{$id}.html",
		target: "{$id}",
		start:  1,
		end:    21,
	}

	res = append(append(res, r1), r2)
	return
}

func main() {
	n := flag.Int("n", 100, "how many rows by created")
	filePath := flag.String("path", "/var/nginx/logs/dia.log", "log file path")
	flag.Parse()
	var list []string
	fmt.Println(*n, *filePath)

	res := ruleResource()

	for _, v := range res {
		if len(v.target) == 0 {
			list = append(list, v.url)
		} else {
			for i := v.start; i <= v.end; i++ {
				urlStr := strings.Replace(v.url, v.target, strconv.Itoa(i), -1)
				list = append(list, urlStr)
			}
		}
	}

	fmt.Println(list)
}
